@extends('admin.layout.main')
@section('content')
    <!-- iCheck for checkboxes and radio inputs -->
    <link rel="stylesheet" href="{{asset('/adminlte/plugins/iCheck/all.css')}}">
    <section class="content-header">
      <h1>
        代理审核
      </h1>
      <ol class="breadcrumb">
        <li><a href="javascript:void(0)"><i class="fa fa-dashboard"></i> 游戏代理</a></li>
      </ol>
    </section>
    <section class="content">
        <!-- Small boxes (Stat box) -->
        <div class="row">
            <div class="col-lg-12 col-xs-6">
                <div class="box">
                    <div class="box-header with-border">
                        <div class="row">
                            <div class="col-sm-10">

                            </div>
                        </div> 
                    </div>
                    
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered table-hover" id="user-list">
                            <div class="dataTables_filter">
                                <form action="/admin/superagent_audit/index" method="GET">
                                    <button type="submit" class="btn btn-info btn-sm">查询:</button><input type="search" placeholder="请输入关键字" name="keywords" class="form-control input-sm" value="{{$keywords}}">
                                </form>
                            </div>
                            <thead>
                                <tr>
                                    <th>电话</th>
                                    <th>姓名</th>
                                    <th>申请时间</th>
                                    <th>地区</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody> 
                                @foreach($agents as $agent)
                                    <tr id="{{$agent->id}}">
                                        <td>{{$agent->mobile}}</td>
                                        <td>{{$agent->realname}}</td>
                                        <td>{{$agent->apply_at}}</td>
                                        <td>{{$agent->address}}</td>
                                        <td>
                                            <a href="javascript:void(0)" class="group-edit"><i class="fa fa-eye"></i>审核</a>
                                            <a href="javascript:void(0)" class="btn-remove"><i class="fa fa-remove"></i>删除</a>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                        {{$agents->links()}}
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- datepicker -->
    <script src="{{asset('/adminlte/plugins/datepicker/bootstrap-datepicker.js')}}"></script>
    <!-- iCheck 1.0.1 -->
    <script src="{{asset('/adminlte/plugins/iCheck/icheck.min.js')}}"></script>
    <script type="text/javascript">
        $(function () {
            $('#user-list').DataTable({
              "paging": false,
              "lengthChange": false,
              "searching": false,
              "info": false,
              "autoWidth": true,
              "columns": [
                {"orderable": false},
                {"orderable": false},
                {"orderable": true},
                {"orderable": true},
                {"orderable": false}
              ]
            });
        });

        $('.all_check').click(function(){
            $('.checkbox_member').click();
        });

        $('#datepicker').datepicker({
          autoclose: true,
          endDate: new Date()
        });

        $('.group-edit').click(function(){
            var aid = $(this).parents('tr').attr('id');
            dialog_params('/admin/superagent/audit/'+aid, '代理审核');
        });

        $('.btn-remove').click(function(){
            var aid = $(this).parents('tr').attr('id');
            bootbox.confirm({
                message: "确定删除代理申请?",
                buttons: {
                    confirm: {
                        label: '是',
                        className: 'btn-success'
                    },
                    cancel: {
                        label: '否',
                        className: 'btn-danger'
                    }
                },
                callback: function (result) {
                    $.ajax({
                        url:"/admin/superagent/remove_apply/"+aid,
                        type:"GET",
                        data:[],
                        dataType:"json",
                        success:function (data) {
                            if (data.flag) {
                                window.location.reload();
                            }
                        }
                    });
                }
            });
        });

    </script>
@endsection      